<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
    <style>
        .box{
            width: 600px;
            height: 250px;
            margin: 0 auto;
            background-color: bisque;
            text-align: center;
            border-radius: 15px 40px;
        }
        .text{
            color: lightskyblue;
        }
        .info{
            color: red;
        }
    </style>
</head>
<body onabort="now()">
    <div class="box">
        <h2>留给你的时间不多了醒醒吧</h2>
        <h3>现在的时间是：</h3>
        <h2 class="text">gsdkjbjbfjbjk</h2>
        <h1 class="info">gsdkjbjbfjbjk</h1>
    </div>
    <script>
        window.onload = function (){
        setInterval(function now(){
            var text = document.querySelector(".text")
            var now = new Date()
            text.innerHTML = now .getFullYear() + "年" + (now.getMonth() + 1) + "月" + now.getDate() + "日" + now.getHours() + "秒"
        },1000)
        setInterval(function(){
            // getTime() 时间戳
            var now = new Date().getTime()
            // 未来时间
            var fut = new Date("2024/1/20 18:18:18").getTime()
            var dat = fut - now
            // 12546465464 1天=24小时 =24*60分钟 =24*60*60秒 = 24*60*60*1000毫秒
            // 进制转换 大单位转化小单位
            var d = Math.floor(dat/ (24*60*60*1000))
            // 时
            var y = Math.floor(dat %(24*60*60*1000) / (24*1000 *60))
            // 分
            const m = Math.floor((dat % (1000 * 60 * 60)) / (1000* 60))
            // 秒
            const s = Math.floor((dat % (1000* 60)) /1000)
            document.querySelector(".info").innerHTML = d + "日" + y + "时" + m + "分" + s +"秒"
        },1000)
    }
    </script>
</body>
</html>